import Ember from 'ember';
import BaseBusiness from '../base-business';
import Pagination from '../pagination';
export default BaseBusiness.extend(Pagination, {
    store: Ember.inject.service("store"),
    queryParams: {
        id: {
            refreshModel: true
        },
    },
    header_title: '账单详情',
    model() {
        return {};
    },
    doQuery: function() {
      let curController = this.getCurrentController();
      let customerId = this.getCurrentController().get('id');
      let curCustomer = this.get("store").peekRecord("customer",customerId);
      curController.set("curCustomer",curCustomer);
      let curCustomerName = curCustomer.get("name");
      let chooseTabFlag = curController.get("chooseTabFlag");
      var params = this.pagiParamsSet();
      var filter = {};
      var sort;
      if(chooseTabFlag == "chooseTabOne"){
        filter = $.extend({}, filter, {
            '[rechargeAccount][customer][name@$like]@$or1': curCustomerName
        });
        filter = $.extend({}, filter, {
            '[rechargeStatus][typecode]': "rechargeStatus2"
        });
        params.filter = filter;
        sort = {
            '[createDateTime]': 'desc',
        };
        params.sort = sort;
        var rechargeList = this.findPaged('rechargerecord', params, function(rechargeList) {});
        curController.set("rechargeList", rechargeList);
      }else{
        filter = $.extend({}, filter, {
            '[customer][id]': customerId
        });
        filter = $.extend({}, filter, {
            '[billStatus][typecode]': "billStatus2"
        });
        params.filter = filter;
        sort = {
            '[createDateTime]': 'desc',
        };
        params.sort = sort;
        var customerbillList = this.findPaged('customerbill', params, function(rechargeList) {});
        curController.set("customerbillList", customerbillList);
      }
    },
    setupController(controller, model) {
        this._super(controller, model);
        controller.set("chooseTabFlag","chooseTabOne");
        this.doQuery();

    }
});
